package org.jeecg.modules.ws.service.impl;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.ws.entity.WsCapitalDetail;
import org.jeecg.modules.ws.mapper.WsCapitalDetailMapper;
import org.jeecg.modules.ws.service.IWsCapitalDetailService;
import org.jeecg.modules.ws.util.CapitalExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * @Description: 资金支付详情
 * @Author: jeecg-boot
 * @Date:   2025-04-11
 * @Version: V1.0
 */
@Service
public class WsCapitalDetailServiceImpl extends ServiceImpl<WsCapitalDetailMapper, WsCapitalDetail> implements IWsCapitalDetailService {
    @Autowired
    private CapitalExcelUtil capitalExcelUtil;

    @Override
    public Result<?> importTempExcel(MultipartFile file) {
        try {
            InputStream inputStream = file.getInputStream();
            capitalExcelUtil.importCapitalDetail(inputStream);
        } catch (IOException e) {
            return Result.error("导入失败");
        } finally {
            try {
                file.getInputStream().close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return  Result.OK();
    }
}
